<script>
    let quantity = 2
    let product = {
        price: 10,
        quantity
    }

    let total = 0
    let effect = () => { total = product.price * product.quantity }

    Object.defineProperty(product, 'quantity', {
        set(value) {
            quantity = value
            effect()
        },
        get() { return quantity }
    })
</script>